﻿using System;
using SharpSqlAnalyzer.nodes;

namespace SharpSqlAnalyzer.stmt.db2
{
	// Token: 0x020001D3 RID: 467
	public class TDb2CreateProcedure : TStoredProcedureSqlStatement
	{
		// Token: 0x06000FAA RID: 4010 RVA: 0x0030BE3B File Offset: 0x0030A03B
		public TDb2CreateProcedure(EDbVendor dbvendor) : base(dbvendor)
		{
			this.sqlstatementtype = ESqlStatementType.sstdb2createprocedure;
		}

		// Token: 0x06000FAB RID: 4011 RVA: 0x0030BE4F File Offset: 0x0030A04F
		internal override void buildsql()
		{
		}

		// Token: 0x06000FAC RID: 4012 RVA: 0x0030BE51 File Offset: 0x0030A051
		internal override void clear()
		{
		}

		// Token: 0x06000FAD RID: 4013 RVA: 0x0030BE53 File Offset: 0x0030A053
		internal override string getasprettytext()
		{
			return "";
		}

		// Token: 0x06000FAE RID: 4014 RVA: 0x0030BE5A File Offset: 0x0030A05A
		internal virtual void iterate(TVisitorAbs pvisitor)
		{
		}

		// Token: 0x170002EC RID: 748
		// (get) Token: 0x06000FAF RID: 4015 RVA: 0x0030BE5C File Offset: 0x0030A05C
		public override TObjectName StoredProcedureName
		{
			get
			{
				return this.procedureName;
			}
		}

		// Token: 0x170002ED RID: 749
		// (get) Token: 0x06000FB0 RID: 4016 RVA: 0x0030BE64 File Offset: 0x0030A064
		// (set) Token: 0x06000FB1 RID: 4017 RVA: 0x0030BE6C File Offset: 0x0030A06C
		public virtual TObjectName ProcedureName
		{
			get
			{
				return this.procedureName;
			}
			set
			{
				this.procedureName = value;
			}
		}

		// Token: 0x06000FB2 RID: 4018 RVA: 0x0030BE78 File Offset: 0x0030A078
		public override int doParseStatement(TCustomSqlStatement psql)
		{
			if (this.rootNode == null)
			{
				return -1;
			}
			TCreateProcedureSqlNode tcreateProcedureSqlNode = (TCreateProcedureSqlNode)this.rootNode;
			TCompoundSqlNode compoundSqls = tcreateProcedureSqlNode.CompoundSqls;
			base.doParseStatement(psql);
			this.procedureName = tcreateProcedureSqlNode.ProcedureName;
			this.ParameterDeclarations = tcreateProcedureSqlNode.Parameters;
			base.DatabaseObjects.Add(this.procedureName);
			if (this.ParameterDeclarations != null)
			{
				for (int i = 0; i < this.ParameterDeclarations.size(); i++)
				{
					this.TopStatement.SymbolTable.Push(new TSymbolTableItem(9, this, this.ParameterDeclarations.getParameterDeclarationItem(i)));
				}
			}
			if (compoundSqls != null)
			{
				if (compoundSqls.DeclareStmts != null)
				{
					compoundSqls.DeclareStmts.doParse(this, ESqlClause.unknown);
					for (int j = 0; j < compoundSqls.DeclareStmts.size(); j++)
					{
						this.TopStatement.SymbolTable.Push(new TSymbolTableItem(10, this, compoundSqls.DeclareStmts.getStatementSqlNode(j).Stmt));
						this.DeclareStatements.add(compoundSqls.DeclareStmts.getStatementSqlNode(j).Stmt);
					}
				}
				if (compoundSqls.Stmts != null)
				{
					compoundSqls.Stmts.doParse(this, ESqlClause.unknown);
					for (int k = 0; k < compoundSqls.Stmts.size(); k++)
					{
						this.BodyStatements.add(compoundSqls.Stmts.getStatementSqlNode(k).Stmt);
					}
				}
				if (compoundSqls.DeclareStmts != null)
				{
					for (int l = 0; l < compoundSqls.DeclareStmts.size(); l++)
					{
						this.TopStatement.SymbolTable.Pop();
					}
				}
			}
			if (this.ParameterDeclarations != null)
			{
				for (int m = 0; m < this.ParameterDeclarations.size(); m++)
				{
					this.TopStatement.SymbolTable.Pop();
				}
			}
			return 0;
		}

		// Token: 0x06000FB3 RID: 4019 RVA: 0x0030C03E File Offset: 0x0030A23E
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x06000FB4 RID: 4020 RVA: 0x0030C050 File Offset: 0x0030A250
		public override void acceptChildren(TParseTreeVisitor v)
		{
			v.preVisit(this);
			if (this.ParameterDeclarations != null)
			{
				this.ParameterDeclarations.accept(v);
			}
			if (this.DeclareStatements.size() > 0)
			{
				this.DeclareStatements.accept(v);
			}
			if (this.BodyStatements.size() > 0)
			{
				this.BodyStatements.accept(v);
			}
			v.postVisit(this);
		}

		// Token: 0x0400137D RID: 4989
		private TObjectName procedureName;
	}
}
